import 'package:safetymonitor/generated/json/base/json_convert_content.dart';
import 'package:safetymonitor/app/data/entities/application/preventive_rectification_entity.dart';

PreventiveRectificationEntity $PreventiveRectificationEntityFromJson(Map<String, dynamic> json) {
  final PreventiveRectificationEntity preventiveRectificationEntity = PreventiveRectificationEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    preventiveRectificationEntity.id = id;
  }
  final String? preventiveName = jsonConvert.convert<String>(json['preventiveName']);
  if (preventiveName != null) {
    preventiveRectificationEntity.preventiveName = preventiveName;
  }
  final int? companyId = jsonConvert.convert<int>(json['companyId']);
  if (companyId != null) {
    preventiveRectificationEntity.companyId = companyId;
  }
  final String? companyName = jsonConvert.convert<String>(json['companyName']);
  if (companyName != null) {
    preventiveRectificationEntity.companyName = companyName;
  }
  final int? findTime = jsonConvert.convert<int>(json['findTime']);
  if (findTime != null) {
    preventiveRectificationEntity.findTime = findTime;
  }
  final int? rectificationDeadline = jsonConvert.convert<int>(json['rectificationDeadline']);
  if (rectificationDeadline != null) {
    preventiveRectificationEntity.rectificationDeadline = rectificationDeadline;
  }
  final dynamic uploaderId = json['uploaderId'];
  if (uploaderId != null) {
    preventiveRectificationEntity.uploaderId = uploaderId;
  }
  final dynamic uploaderName = json['uploaderName'];
  if (uploaderName != null) {
    preventiveRectificationEntity.uploaderName = uploaderName;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    preventiveRectificationEntity.status = status;
  }
  final String? rectificationRequire = jsonConvert.convert<String>(json['rectificationRequire']);
  if (rectificationRequire != null) {
    preventiveRectificationEntity.rectificationRequire = rectificationRequire;
  }
  final String? source = jsonConvert.convert<String>(json['source']);
  if (source != null) {
    preventiveRectificationEntity.source = source;
  }
  final String? problemDesc = jsonConvert.convert<String>(json['problemDesc']);
  if (problemDesc != null) {
    preventiveRectificationEntity.problemDesc = problemDesc;
  }
  final String? fileUrl = jsonConvert.convert<String>(json['fileUrl']);
  if (fileUrl != null) {
    preventiveRectificationEntity.fileUrl = fileUrl;
  }
  final dynamic acceptanceStatus = json['acceptanceStatus'];
  if (acceptanceStatus != null) {
    preventiveRectificationEntity.acceptanceStatus = acceptanceStatus;
  }
  final dynamic acceptanceDesc = json['acceptanceDesc'];
  if (acceptanceDesc != null) {
    preventiveRectificationEntity.acceptanceDesc = acceptanceDesc;
  }
  final dynamic acceptanceFileUrl = json['acceptanceFileUrl'];
  if (acceptanceFileUrl != null) {
    preventiveRectificationEntity.acceptanceFileUrl = acceptanceFileUrl;
  }
  final int? createTime = jsonConvert.convert<int>(json['createTime']);
  if (createTime != null) {
    preventiveRectificationEntity.createTime = createTime;
  }
  final dynamic rectificationPersonName = json['rectificationPersonName'];
  if (rectificationPersonName != null) {
    preventiveRectificationEntity.rectificationPersonName = rectificationPersonName;
  }
  final List<dynamic>? recordDOS = (json['recordDOS'] as List<dynamic>?)?.map(
          (e) => e).toList();
  if (recordDOS != null) {
    preventiveRectificationEntity.recordDOS = recordDOS;
  }
  return preventiveRectificationEntity;
}

Map<String, dynamic> $PreventiveRectificationEntityToJson(PreventiveRectificationEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['preventiveName'] = entity.preventiveName;
  data['companyId'] = entity.companyId;
  data['companyName'] = entity.companyName;
  data['findTime'] = entity.findTime;
  data['rectificationDeadline'] = entity.rectificationDeadline;
  data['uploaderId'] = entity.uploaderId;
  data['uploaderName'] = entity.uploaderName;
  data['status'] = entity.status;
  data['rectificationRequire'] = entity.rectificationRequire;
  data['source'] = entity.source;
  data['problemDesc'] = entity.problemDesc;
  data['fileUrl'] = entity.fileUrl;
  data['acceptanceStatus'] = entity.acceptanceStatus;
  data['acceptanceDesc'] = entity.acceptanceDesc;
  data['acceptanceFileUrl'] = entity.acceptanceFileUrl;
  data['createTime'] = entity.createTime;
  data['rectificationPersonName'] = entity.rectificationPersonName;
  data['recordDOS'] = entity.recordDOS;
  return data;
}

extension PreventiveRectificationEntityExtension on PreventiveRectificationEntity {
  PreventiveRectificationEntity copyWith({
    int? id,
    String? preventiveName,
    int? companyId,
    String? companyName,
    int? findTime,
    int? rectificationDeadline,
    dynamic uploaderId,
    dynamic uploaderName,
    int? status,
    String? rectificationRequire,
    String? source,
    String? problemDesc,
    String? fileUrl,
    dynamic acceptanceStatus,
    dynamic acceptanceDesc,
    dynamic acceptanceFileUrl,
    int? createTime,
    dynamic rectificationPersonName,
    List<dynamic>? recordDOS,
  }) {
    return PreventiveRectificationEntity()
      ..id = id ?? this.id
      ..preventiveName = preventiveName ?? this.preventiveName
      ..companyId = companyId ?? this.companyId
      ..companyName = companyName ?? this.companyName
      ..findTime = findTime ?? this.findTime
      ..rectificationDeadline = rectificationDeadline ?? this.rectificationDeadline
      ..uploaderId = uploaderId ?? this.uploaderId
      ..uploaderName = uploaderName ?? this.uploaderName
      ..status = status ?? this.status
      ..rectificationRequire = rectificationRequire ?? this.rectificationRequire
      ..source = source ?? this.source
      ..problemDesc = problemDesc ?? this.problemDesc
      ..fileUrl = fileUrl ?? this.fileUrl
      ..acceptanceStatus = acceptanceStatus ?? this.acceptanceStatus
      ..acceptanceDesc = acceptanceDesc ?? this.acceptanceDesc
      ..acceptanceFileUrl = acceptanceFileUrl ?? this.acceptanceFileUrl
      ..createTime = createTime ?? this.createTime
      ..rectificationPersonName = rectificationPersonName ?? this.rectificationPersonName
      ..recordDOS = recordDOS ?? this.recordDOS;
  }
}